package com.yejiarong.influxdb.controller;

import com.yejiarong.common.tools.HttpResult;
import com.yejiarong.influxdb.api.bean.request.SavePointRequest;
import com.yejiarong.influxdb.service.IInfluxdbService;
import org.springframework.web.bind.annotation.*;

/**
 * @author YeJR
 */
@RestController
@RequestMapping(value = "/influxdb")
public class InfluxdbController {

    private final IInfluxdbService influxdbService;

    public InfluxdbController(IInfluxdbService influxdbService) {
        this.influxdbService = influxdbService;
    }

    /**
     * 收集 point
     * @param exchange 消息队列
     * @param saveRequest point
     * @return HttpResult
     */
    @PostMapping(value = "/collectPoint/{exchange}")
    public HttpResult<Void> collectPoint(@PathVariable(value = "exchange") String exchange, @RequestBody SavePointRequest saveRequest) {
        influxdbService.collectPoint(exchange, saveRequest);
        return HttpResult.success();
    }

}
